#ifndef INPUT_MAN_H
#define INPUT_MAN_H

#include <OIS.h>

#include "StateManager.h"

namespace Ogre {
    class RenderWindow;
}

namespace pong {
	/** Input manager. Captures input and forwards events to 
	 *  the associated StateManager **/
    class InputManager : public OIS::MouseListener, 
                         public OIS::KeyListener
    {
    protected:
		OIS::InputManager* inputMan;
		OIS::Mouse*        mouse;
		OIS::Keyboard*     keys;

        StateManager* stateMan;

    public:
        InputManager(StateManager* const sm)
           : inputMan(0), mouse(0), keys(0), 
             stateMan(sm)
        {}
        ~InputManager(void);

        void init(Ogre::RenderWindow* const);

		/// Capture the current input. Call to generate events
        void capture(void);

        virtual bool keyPressed(const OIS::KeyEvent& e) {
            return stateMan->processKeyPress(e);
        }
        virtual bool keyReleased(const OIS::KeyEvent& e) {
            return stateMan->processKeyRelease(e);
        }

        virtual bool mouseMoved(const OIS::MouseEvent& e) {
            return stateMan->processMouseMove(e);
        }
        virtual bool mousePressed(const OIS::MouseEvent& e, OIS::MouseButtonID btn) {
            return stateMan->processMousePress(e, btn);
        }
        virtual bool mouseReleased(const OIS::MouseEvent& e, OIS::MouseButtonID btn) {
            return stateMan->processMouseRelease(e, btn);
        }
	};
}
#endif